package com.example.demo.controller;

import com.example.demo.config.AppConfig;
import com.example.demo.pojo.Result;
import com.example.demo.pojo.ResultCode;
import com.example.demo.pojo.User;
import com.example.demo.service.Impl.UserServiceImpl;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody User user) throws IOException {

        User user1 =userService.login(user.getUsername(),user.getPassword());
        //HttpSession session=request.getSession(true);
        //session.getAttribute(AppConfig.USER_SESSION,user);
        if(user1==null)
        {
            return Result.fail("出现错误");
        }
        return Result.success();
    }
}
